﻿using KalevaAalto.DataPart.Excel.Base;
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KalevaAalto.DataPart.Models;

namespace KalevaAalto.DataPart.Excel.Epplus
{
    internal class EpplusWorksheet : BaseWorksheet
    {
        private ExcelWorksheet _worksheet;
        public EpplusWorksheet(BaseWorksheets worksheets,ExcelWorksheet worksheet):base(worksheets)
        {
            _worksheet = worksheet; 
        }

        public override BaseRange Cells => new EpplusRange(this,_worksheet.Cells);

        public override IStyle Sytle => new EpplusStyle(_worksheet.Cells.Style);

        public override string Name { get => _worksheet.Name; set => _worksheet.Name = value; }

        public override BaseRange Range => new EpplusRange(this, _worksheet.Cells[_worksheet.Dimension.Address]);

        public override BaseView View => new EpplusView(_worksheet.View);


        public override Task TestAsync()
        {
            _worksheet.PrinterSettings.Orientation = eOrientation.Landscape; // 横向
            _worksheet.PrinterSettings.PaperSize = ePaperSize.A5; // A5大小
            _worksheet.PrinterSettings.TopMargin = 0.5M; // 上边距（单位：英寸）
            _worksheet.PrinterSettings.BottomMargin = 0.5M; // 下边距（单位：英寸）
            _worksheet.PrinterSettings.LeftMargin = 0.25M; // 左边距（单位：英寸）
            _worksheet.PrinterSettings.RightMargin = 0.25M; // 右边距（单位：英寸）
            _worksheet.PrinterSettings.FitToPage = true; // 将工作表调整为一页

            return Task.CompletedTask;

            
        }

    }
}
